package com.smartstate.iot.controller;

import com.smartstate.common.web.httpResult.ApiResultIgnore;
import com.smartstate.iot.entity.vo.GatewayInfoVo;
import com.smartstate.iot.mqtt.service.TopicService;
import com.smartstate.iot.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = {"网关管理"})
@RequestMapping("/gateway")
public class GatewayMangerController {
    @Autowired
    private TopicService topicService;

    @GetMapping("/list")
    @ApiResultIgnore
    @ApiOperation(value = "查询所有网关")
    public List<GatewayInfoVo> findAllGateway(){
        return topicService.getAll();
    }

    @GetMapping("/cpu")
    @ApiResultIgnore
    @ApiOperation(value = "查询cpu信息")
    public int getCpuInfo(@RequestParam String deviceName){
        return topicService.getCpuInfo(deviceName);
    }

    @GetMapping("/memory")
    @ApiResultIgnore
    @ApiOperation(value = "查询内存信息")
    public int getMemoryInfo(@RequestParam String deviceName){
        return topicService.getMemoryInfo(deviceName);
    }

    @GetMapping("/details")
    @ApiResultIgnore
    @ApiOperation(value = "查看盒子与设备所属信息")
    public ResultVO getDetails(@RequestParam String deviceId){
        return topicService.getDetails(deviceId);
    }

}
